package com.ruoyi.job.task;

import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.TimeUtils;
import com.ruoyi.common.core.web.domain.CommonEntity;
import com.ruoyi.job.remoteService.HualalaRemoteService;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.Date;

@Component("hualalaTask")
public class HualalaTask {

    @Resource
    private HualalaRemoteService hualalaRemoteService;
    public void saveAllShop()
    {
        hualalaRemoteService.saveAllShop();
    }


   // @PostMapping("/saveShopMenu")
    public void saveShopMenu(String shopId)
    {
        Long s=Long.parseLong(shopId);
        hualalaRemoteService.saveShopMenu(s);
    }


  //  @PostMapping("/saveShopBillDetail")
    public void saveShopBillDetail(String shopId,String reportDate) throws ParseException {
        Long s1=Long.parseLong(shopId);
        Long s2=Long.parseLong(reportDate);
        CommonEntity entity=new CommonEntity(s1,s2);
        hualalaRemoteService.saveShopBillDetail(entity);
    }

    /**
     * 这个定时任务应该在晚上11点执行，
     * bill-food------->bill-food-report
     * @param flag
     * @param reportDate
     *   // flag=1 表示 把指定月份所有数据执行一下
     *     //flag=2 执行每个特定的时间
     *     //flag=3 执行当前时间
     */

    public void   saveHllShopBillFoodReportday(Integer flag,Integer reportDate)
    {

        CommonEntity entity=new CommonEntity();
        entity.setFlag(flag);
        entity.setReportDate(Long.valueOf(reportDate));
        if(3==entity.getFlag())
        {
            entity.setFlag(2);
            entity.setReportDate(TimeUtils.getStringDateToLong(new Date()));
        }

        hualalaRemoteService.saveHllShopBillFoodReportday(entity);
    }







}
